<?php
/**
 * The loop that displays projects on the portfolio page.
 *
 * @package toekneestuck
 * @subpackage toekneestuck
 * @since toekneestuck 2.0
 */

/* If there are no posts to display, such as an empty archive page */
if ( ! have_posts() ): ?>
<article id="post-0" class="post error404 not-found">
	<h1><?php _e( 'I think I screwed up..', 'toeknee' ); ?></h1>
	<div class="entry-content">
		<p><?php _e( 'Apologies, but no projects were found. I had to have done something wrong for this to happen..', 'toeknee' ); ?></p>
		<?php get_search_form(); ?>
	</div><!-- .entry-content -->
</article>
<?php endif; ?>

<?php while ( have_posts() ) : the_post(); $terms = (array) get_the_terms( get_the_ID(), 'project_type'); ?>
<li data-id="<?php echo sanitize_html_class( 'id-' . get_the_ID() ) ?>" data-cats="<?php echo strtolower( implode(' ', sanitize_html_class( array_map( 'toeknee_get_term_name', $terms) ) ) ); ?>" data-date="<?php echo strtotime( get_the_date(DATE_RFC822) ) ?>">
	<?php printf( '<a href="%1$s" title="View Details of %2$s">%3$s</a>', 
		get_permalink(),
		get_the_title(),
		get_the_post_thumbnail( get_the_ID(), 'portfolio-thumb' ) ? get_the_post_thumbnail( get_the_ID(), 'portfolio-thumb' ) : '<img src="' . home_url( get_bloginfo('template_url') .  '/img/no-image.png') . '" height="125" width="250" />'
	); ?>
	<h2 class="h6"><a href="<?php the_permalink() ?>" title="View Details of <?php the_title() ?>"><?php the_title(); ?></a></h2>
	<div class="details">
		<p><?php the_date() ?></p>
	</div>
</li>
<?php endwhile; ?>